<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="./js/axios.js"></script>
</head>

<body>
  <h1>注册</h1>
  <div>
    <label for="#">用户名</label>
    <input type="text" id="username"><br>
    <label for="#">密码</label>
    <input type="text" id="password"><br>
    <label for="#">年龄</label>
    <input type="text" id="age"><br>
    <label for="#">性别</label>
    <!-- <input  id="sex" type="radio" name="sex" value="男" checked>男
    <input  id="sex" type="radio" name="sex" value="女">女<br> -->
    <select  id="sex">
      <option value="男">男</option>
      <option value="女">女</option>
    </select>
    <button id="user">注册用户</button>
  </div>
  <script>
    user.onclick = async function() {
      const user = username.value
      const pwd = password.value
      const ages = age.value
      const gender = sex.value
      // console.log(user,pwd,ages,gender);

      const { data } = await axios.post('/register', {
        user,ages,gender,pwd,
      })
      console.log(data);
      // if (data) {
      //   console.log('请求成功',data);
      // }else {
      //   console.log('请求失败');
      // }
    }
  </script>
</body>

</html>